package com.heima.user.controller.v1;

import com.heima.common.exception.LeadNewsException;
import com.heima.model.common.dto.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.user.dto.UserRelationDto;
import com.heima.user.service.ApUserFollowRelationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;


/**
 * @author Ronaldo
 * @date 2021/8/13
 */
@RestController
@RequestMapping("/api/v1/user")
@Slf4j
public class ApUserFollowRelationController {

    @Autowired
    private ApUserFollowRelationService apUserFollowRelationService;

    @PostMapping("/user_follow")
    public ResponseResult saveFollowRelation(@RequestBody UserRelationDto userRelationDto){
        log.info("save follow relation by userRelationDto{}",userRelationDto);

        if (Objects.isNull(userRelationDto)){
            throw new LeadNewsException(AppHttpCodeEnum.PARAM_INVALID);
        }
        return apUserFollowRelationService.saveFollowRelation(userRelationDto);
    }
}
